package operations;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddOperation implements IOperations{

    @Override
    public void work(BookList bookList) {
//        System.out.println("新增图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入书名");
        String bookName = scanner.nextLine();
        System.out.println("请输入作者名");
        String authorName = scanner.nextLine();
        System.out.println("请输入价格");
        int bookPrice = scanner.nextInt();
        System.out.println("请输入类型");
        String bookType = scanner.nextLine();

        Book addBook = new Book(bookName,authorName,bookPrice,bookType,false);
        int position = bookList.getUsedSize();

        bookList.setBooks(position,addBook);
        //原使用长度加1
        bookList.setUsedSize(position+1);
        System.out.println("新增成功");
    }
}
